package com.eastfair.messagecenter.handler;


import com.eastfair.messagecenter.enumeration.ChannelType;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * channel->Handler的映射关系
 * 执行发送消息的handler集合点
 * @author ligang
 */
@Component
public class HandlerHolder {

    private Map<ChannelType, Handler> handlers = new HashMap<ChannelType, Handler>(128);

    public void putHandler(ChannelType channelType, Handler handler) {
        handlers.put(channelType, handler);
    }

    public Handler route(ChannelType channelType) {
        return handlers.get(channelType);
    }
}
